#include "LineTest.h"
#include <list>
//CPPUNIT_TEST_SUITE_REGISTRATION (LineTest);

void LineTest::setUp(void) {

	c1 = new Coordinate(10.0f,12.0f);

	p1 = new Point(1, 0.0, 0.0);
	p2 = new Point(2, 10.0, 0.0);
	p3 = new Point(3, 20.0, 0.0);
	p4 = new Point(4, 30.0, 10.0);
	p3->setX(22.0);
	//	p4->setX(33.0);
	//	p3->setY(12.0);

	l1 = new Line(1, p1, p2);
	l2 = new Line(2, p3, p4);

	std::list<Point*> st;
	st.push_back(p1);
	st.push_back(p2);
	st.push_back(p3);

	s1 = new Segment(3, st);
}

void LineTest::tearDown(void) {
	// finally delete objects
	delete p1;
	delete p2;
	delete p3;
	delete p4;
	delete l1;
	delete l2;
	delete s1;
	delete c1;
}

void LineTest::testFunction(void) {
	ublasVector v1 = l1->getForceInPoint(p1);
	ublasVector v2 = l1->getForceInPoint(p2);

	ublasVector v3 = l2->getForceInPoint(p3);
	ublasVector v4 = l2->getForceInPoint(p4);

	CPPUNIT_ASSERT_EQUAL(0.0f,v1(0) );
	CPPUNIT_ASSERT_EQUAL(0.0f,v1(1) );
	CPPUNIT_ASSERT_EQUAL(0.0f,v2(0) );
	CPPUNIT_ASSERT_EQUAL(0.0f,v2(1) );
	CPPUNIT_ASSERT_EQUAL(10.0f,c1->x);
	CPPUNIT_ASSERT_EQUAL(12.0f,c1->y);

}

void LineTest::testFunction2(void) {
	cout << endl;
	cout << *(l1->getPoint(0));
	cout << *(l1->getPoint(1));
	cout << "Jacobian :" << endl;
	cout << l1->getJacobian(p1, p1) << endl;
	cout << l1->getJacobian(p1, p2) << endl;
	cout << l1->getJacobian(p2, p1) << endl;
	cout << l1->getJacobian(p2, p2) << endl;
	cout << endl << "Forces : " << endl;
	cout << l1->getForceAll() << endl;
	cout << "Jacobian FULL :" << endl;
	cout << l1->getJacobianAll() << endl;
	cout << "Segment Jacobian FULL :" << endl;
	cout << s1->getJacobianAll() << endl;
	cout << s1->getForceAll() << endl;

	Coordinate c2(2.3f,4.5f);

	c1 = new Coordinate(123.3f,114.5f);
	cout << "c2 :" << c2.x << c2.y << endl;

	cout << "c1 :" << c1->x << c1->y << endl;
}
void LineTest::testFunction4(void) {
	cout << endl;
	cout << l1->toString() << endl;
	cout << l2->toString() << endl;
	cout << s1->toString() << endl;
	cout << p1->toString() << endl;
	cout << p2->toString() << endl;
}
